home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / DDPLUS71.ZIP / IBBS.ZIP / IBBS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-23  |  39.9 KB  |  1,334 lines

  1. (***************************************************************************
  2.  
  3.              Fidonet Compatable InterBBS Unit for inclusion in DDPlus.
  4.                              DreamWARE Communications
  5.               Copyright (c)1993-95 Andy Stewart  All Rights Reserved
  6.                            Last revised March 23, 1995
  7.  
  8.              If you make ANY modifications to this unit, PLEASE sent
  9.             it to Andy Stewart @ 1:2230/146 or Bob Dalton @ 1:391/3010
  10.                for possible inclusion in the next release of DDPlus.
  11.  
  12.  ***************************************************************************)
  13. unit ibbs;
  14.  
  15. INTERFACE
  16.  
  17. (***************************************************************************
  18.   Var-String checking switch MUST be set to OFF for the copy routine.
  19.  ***************************************************************************)
  20.  
  21. {$V-}
  22.  
  23. (***************************************************************************
  24.   Remove '.' to use procedure read_all_messages();
  25.  ***************************************************************************)
  26.  
  27. {$DEFINE READ_EM}
  28.  
  29. (***************************************************************************
  30.   Global Variable
  31.  ***************************************************************************)
  32.  
  33. var
  34.  this_system_address,    { Holds this system's address }
  35.  to_system_address,      { Holds the 'to' system's address }
  36.  netmailpath,            { Holds netmail path }
  37.  the_doorname,           { Holds the Door's name }
  38.  doorpath,               { Holds the Door's path }
  39.  filepath,               { Holds file path }
  40.  outfiles,               { Holds name of directory with files to be compressed }
  41.  infiles,                { Holds name of directory to decompress files to }
  42.  outzip,                 { Holds name of directory with outgoing *.ZIP files }
  43.  inzip: string;          { Holds name of directory with incoming *.ZIP files }
  44.  
  45. (***************************************************************************
  46.   The only five procedures available externally.
  47.  ***************************************************************************)
  48.  
  49. {$ifdef READ_EM}
  50. procedure read_all_msgs;
  51. {$endif}
  52. function convert_address(s: string): string;
  53. procedure get_ibbs_incoming;
  54. procedure make_ibbs_outgoing(thefile: string; killfiles: boolean);
  55. procedure make_multi_ibbs_outgoing;
  56.  
  57. IMPLEMENTATION
  58.  
  59. (***************************************************************************
  60.   You can play with the memory settings (goes in your main *.PAS file, not
  61.   in this unit, but needed to let you know <g>) to get the proper setting
  62.   for your application.  Set the heapmax too low and you may get a overflow
  63.   RTE.
  64.  ***************************************************************************)
  65.  
  66. {.$M $4000, 0, 100000}
  67.  
  68. uses
  69.  dos,
  70.  crt;
  71.  
  72. (***************************************************************************
  73.   Fidonet message structure.
  74.  ***************************************************************************)
  75.  
  76. const
  77.  max_msg_lines=150;
  78.  
  79. type
  80.  text_buff   = array[1..10000] of char;    { Set up Text Buffer }
  81.  message_rec = record                      { Begin *.MSG structure }
  82.  from        : string[35];
  83.  too         : string[35];
  84.  subject     : string[72];
  85.  datetime    : string[19];
  86.  timesread,
  87.  destnode,
  88.  orignode,
  89.  cost,
  90.  orignet,
  91.  destnet,
  92.  replyto,
  93.  attribute,
  94.  nextreply   : word;
  95.  junk        : array[1..12] of byte;
  96.  lines       : integer;
  97.  text        : array[1..max_msg_lines] of string[85];
  98. end;                                       { End *.MSG structure }
  99.  
  100. (***************************************************************************
  101.   Local - Global Variables
  102.  ***************************************************************************)
  103.  
  104. var
  105.  cur_msg: message_rec;         { Message record }
  106.  oldfilemode: byte;            { Holds the old filemode }
  107.  
  108. (***************************************************************************
  109.   function exist();  Returns TRUE if file 'filename' exists, else FALSE.
  110.  ***************************************************************************)
  111.  
  112. function exist(filename: string): boolean;
  113. var
  114.  dirinfo: searchrec;
  115.  
  116. begin
  117.  findfirst(filename, anyfile, dirinfo);
  118.  if (doserror = 0) then exist:= true else exist:= false;
  119. end;
  120.  
  121. (***************************************************************************
  122.   function direxist();  Returns TRUE if directory 'dir' exists, else FALSE.
  123.  ***************************************************************************)
  124.  
  125. function direxist(dir : dirstr): boolean;
  126. var
  127.  fattr: word;
  128.  temp: file;
  129.  
  130. begin
  131.  assign(temp, (dir+'.')); getfattr(temp, fattr);
  132.  if (doserror<>0) then direxist:=false else direxist:=((fattr and directory)<>0);
  133. end;
  134.  
  135. (***************************************************************************
  136.   procedure makepath();  Makes FULL path 'dir'.
  137.  ***************************************************************************)
  138.  
  139. procedure makepath(dir: string);
  140. var
  141.  retry, b: byte;
  142.  error: word;
  143.  tempdir, dir2, thisdir: string;
  144.  
  145. begin
  146.   getdir(0,thisdir);
  147.   while dir[Length(dir)]='\' do dec(dir[0]);
  148.   dir2:='';
  149.   repeat
  150.    b:=pos('\',dir);
  151.    if (b<>0) then
  152.     begin
  153.      dir2:=dir2+copy(dir,1,b);
  154.      dir:=copy(dir,b+1,length(dir)-b);
  155.     end else dir2:=dir2+dir;
  156.     tempdir:=dir2;
  157.     if (length(tempdir)>3) then while tempdir[length(tempdir)]='\' do dec(tempdir[0]);
  158.     repeat
  159.      {$I-} chdir(tempdir);  {$I+}
  160.       error:=ioresult;
  161.       if (error<>0)then
  162.        begin
  163.         {$I-} mkdir(tempdir); {$I+}
  164.         error:=ioresult;
  165.        end;
  166.       if (error<>0) then inc(retry) else retry:=0;
  167.     until (error=0) or (retry>3);
  168.   until (b=0) or (error<>0);
  169.   chdir(thisdir);
  170. end;
  171.  
  172. (***************************************************************************
  173.   procedure killdir();  Deletes directory 'path' and everything inside.
  174.  ***************************************************************************)
  175.  
  176. procedure killdir(path: pathstr);
  177. Var
  178.  f: file;
  179.  fileInfo: searchrec;
  180.  path2: pathstr;
  181.  s: string;
  182.  
  183. begin
  184.  if path[length(path)]='\' then delete(path,length(path),1);
  185.  findfirst(path+'\*.*',anyfile,fileInfo);
  186.  while doserror=0 do
  187.   begin
  188.    if (fileinfo.name[1]<>'.')and(fileinfo.attr<>volumeid) then
  189.     if ((fileinfo.attr and directory)=directory) then
  190.       begin
  191.        path2:=path+'\'+fileinfo.name;
  192.        killdir(path2);
  193.       end
  194.      else
  195.       if ((fileinfo.attr and volumeid)<>volumeid) then
  196.        begin
  197.         assign(f,path+'\'+fileinfo.name);
  198.         erase(f);
  199.        end;
  200.       findnext(fileinfo);
  201.     end;
  202.    if (doserror=18) and not ((length(path)=2) and (path[2]=':')) then rmdir(path);
  203. end;
  204.  
  205. (***************************************************************************
  206.   procedure killmsg();  Deletes file 'path' if it exists.
  207.  ***************************************************************************)
  208.  
  209. procedure killmsg(path: string);
  210. var
  211.  f: file;
  212.  
  213. begin
  214.  if exist(path) then
  215.   begin
  216.    assign(f,path);
  217.    erase(f);
  218.   end;
  219. end;
  220.  
  221. (***************************************************************************
  222.   function cstr();  Converts a longint and under to a string and returns it.
  223.  ***************************************************************************)
  224.  
  225. function cstr(i:longint):string;
  226. var
  227.  c: string;
  228.  
  229. begin
  230.  str(i,c);
  231.  cstr:=c;
  232. end;
  233.  
  234. (***************************************************************************
  235.   function upstr();  Converts a string to all uppercase and returns it.
  236.  ***************************************************************************)
  237.  
  238. function upstr(s1: string): string;
  239. var
  240.  s2 : string;
  241.  i1: integer;
  242. begin
  243.  s2:='';
  244.  for i1:=1 to length(s1) do s2:=s2+upcase(s1[i1]);
  245.  upstr:=s2;
  246. end;
  247.  
  248. (***************************************************************************
  249.   function value();  Converts a string to a longint and returns it.
  250.  ***************************************************************************)
  251.  
  252. function value(I:string): longint;
  253. var
  254.  n: longint;
  255.  n1: integer;
  256.  
  257. begin
  258.  val(i,n,n1);
  259.  if n1<>0 then
  260.   begin
  261.    i:=copy(i,1,n1-1);
  262.    val(i,n,n1)
  263.   end;
  264.  value:=n;
  265.  if i='' then value:=0;
  266. end;
  267.  
  268. (***************************************************************************
  269.   function field(); Returns a substring based on a delimiter you pass.
  270.  ***************************************************************************)
  271.  
  272. function field(s: string; c: char; inst: byte): string;
  273. var
  274.  build: string;
  275.  ik, k, kmax: word;
  276.  
  277. begin
  278.  s:= s+c+c;
  279.  ik:= 0;
  280.  kmax := length(s);
  281.  build:= '';
  282.  k:= 0;
  283.  while (k <= kmax+1) and (ik < inst) do
  284.   begin
  285.    inc(k);
  286.    If s[k] = c then
  287.     begin
  288.      inc(ik);
  289.      if ik <> inst then build:= '';
  290.     end else build:= build + s[k];
  291.   end;
  292.  if (ik <> inst) then build := '';
  293.  field:= build;
  294. End;
  295.  
  296. (***************************************************************************
  297.   procedure onek(); Repeats until keypress is in string 's'.  Return key as
  298.   var 'c'.
  299.  ***************************************************************************)
  300.  
  301. procedure onek(var c: char; s: string);
  302. begin
  303.  repeat
  304.   c:=readkey;
  305.   c:=upcase(c);
  306.  until (pos(c,s)<>0);
  307. end;
  308.  
  309. (***************************************************************************
  310.   function doexec(); Exec() function with a path search.  Returns DOSERROR.
  311.  ***************************************************************************)
  312.  
  313. function doexec(a, b: string): integer;
  314. var
  315.  Pgm: Pathstr;
  316.  Temp: string;
  317.  
  318. begin
  319.  Pgm:='';
  320.  if pos('.',a)<>0 then if not exist(a) then Pgm:= FSearch(a,getenv('PATH')) else Pgm:=a else
  321.   begin
  322.    temp:=a+'.BAT';
  323.    if not exist(temp) then Pgm:=FSearch(Temp,getenv('PATH')) else Pgm:=Temp;
  324.    if Pgm='' then
  325.     begin
  326.      temp:=a+'.COM';
  327.      if not exist(temp) then Pgm:=FSearch(Temp,getenv('PATH')) else Pgm:=Temp;
  328.     end;
  329.    if Pgm='' then
  330.     begin
  331.      temp:=a+'.EXE';
  332.      if not exist(temp) then Pgm:=FSearch(Temp,getenv('PATH')) else Pgm:=Temp;
  333.     end;
  334.   end;
  335.  if Pgm<>'' then
  336.   begin
  337.    If Pos('.BAT', Pgm) <> 0 then
  338.     begin
  339.      b := '/C '+Pgm+' '+b;
  340.      Pgm := GetEnv('COMSPEC');
  341.     end;
  342.   dos.exec(pgm,b);
  343.   doexec:=doserror;
  344.  end;
  345. end;
  346.  
  347. (***************************************************************************
  348.                               Begin Copy Routines
  349.  ***************************************************************************)
  350.  
  351. type
  352.  ctype  = (cMOVE,cCOPY);  { cMOVE=Copy and Delete, cCOPY=Copy and NO Delete }
  353.  DTARec =  record         { Data Record }
  354.  filler : array [1..21] of byte;
  355.  attr   : byte;
  356.  time,
  357.  date   : word;
  358.  size   : longint;
  359.  name   : string [12];
  360. end;
  361.  
  362. var
  363.  OK : integer;    { Holds doserror }
  364.  IP,OP : pathstr; { Infile, Outfile }
  365.  
  366. (***************************************************************************
  367.    procedure putfattr(); Changes file attributes.  .
  368.    Called from copy_file();.
  369.  ***************************************************************************)
  370.  
  371. procedure putfattr(FName:string; Rdonly, Hid, Sys, Arch:Boolean);
  372. var
  373.  r: registers;
  374.  
  375. begin
  376.  FillChar(R,Sizeof(R),0);
  377.  FName := FName+#0;
  378.  with R do
  379.   begin
  380.    AH := $43; AL := 1;
  381.    DS := Seg(FName); DX := ofs(FName)+1;
  382.    if Rdonly then CL := CL or $01;
  383.    if Hid then CL := CL or $02;
  384.    if Sys then CL := CL or $04;
  385.    if Arch then CL := CL or $20;
  386.    msdos(R);
  387.   end;
  388. end;
  389.  
  390. (***************************************************************************
  391.    function Copier();  Does the real copying/moving.
  392.    Called from copy_file();.
  393.  ***************************************************************************)
  394.  
  395. function Copier(cWhat: ctype; var orig: string; var nName: string) : integer;
  396. const
  397.  bufsize = $C000;                 { Approx. 48k }
  398.  
  399. type
  400.  fileBuffer = array [1..bufsize] of byte;
  401.  
  402. var
  403.  regs: registers;
  404.  src,dst: integer;
  405.  bsize,osize: longint;
  406.  buffer : ^fileBuffer;
  407.  DTABlk : DTARec;
  408.  fError : boolean;
  409.  
  410. (***************************************************************************
  411.    function checkerror(); Returns TRUE if error, FALSE if not.
  412.    Called from copy_file();.
  413.  ***************************************************************************)
  414.  
  415.  function checkerror(err: integer) : boolean;
  416.   begin
  417.    checkerror:= (Err <> 0);
  418.    ferror:= (Err <> 0);
  419.    copier:= err;
  420.   end;
  421.  
  422. (***************************************************************************
  423.    procedure delfile();) Delete file 'fname' if cMOVE is specified.
  424.    Called from copy_file();.
  425.  ***************************************************************************)
  426.  
  427.  procedure delfile(var fname: string);
  428.  var
  429.   regs: registers;
  430.  
  431.  begin
  432.   with regs do
  433.    begin
  434.     ah := $43;
  435.     al := 1;
  436.     cx := 0;
  437.     ds := Seg(fName[1]);
  438.     dx := ofs(fName[1]);
  439.     msdos(regs);
  440.     if checkerror(Flags and 1) then exit else
  441.      begin
  442.       ah := $41;
  443.       msdos(regs);
  444.       if checkerror(Flags and 1) then exit;
  445.      end;
  446.     end;
  447.    end;
  448.  
  449. begin
  450.  Copier := 0;
  451.  FindFirst(orig,Anyfile,SearchRec(DTABlk));
  452.  if checkerror(dosError) then exit;
  453.  with regs do
  454.   begin
  455.    ah := $3D;
  456.    al := 0;
  457.    ds := Seg(orig[1]);
  458.    dx := ofs(orig[1]);
  459.    msdos(regs);
  460.    if checkerror(Flags and 1) then exit else
  461.     begin
  462.      src := ax;
  463.      ah := $3C;
  464.      cx := 0;
  465.      ds := Seg(nName[1]);
  466.      dx := Ofs(nName[1]);
  467.      msdos(regs);
  468.      if checkerror(Flags and 1) then exit else dst := ax;
  469.     end;
  470.   end;
  471.  osize := DTABlk.size;
  472.  while (osize > 0) and not ferror do
  473.   begin
  474.    if osize > bufsize then bsize := bufsize else bsize := osize;
  475.    if BSize > maxavail then BSize := maxavail;
  476.    getmem (buffer, BSize);
  477.    with regs do
  478.     begin
  479.      ah := $3F;
  480.      bx := src;
  481.      cx := bsize;
  482.      ds := Seg(buffer^);
  483.      dx := ofs(buffer^);
  484.      msdos(regs);
  485.      if checkerror(Flags and 1) then else
  486.       begin
  487.        ah := $40;
  488.        bx := dst;
  489.        msdos(regs);
  490.        if checkerror(Flags and 1) then else  if ax < bsize then checkerror(98) else osize := osize - bsize;
  491.       end;
  492.     end;
  493.    freemem(buffer, BSize);
  494.   end;
  495.  if not ferror and (cWHAT = cMOVE) then
  496.   with regs do
  497.    begin
  498.     ah := $57;
  499.     al := 1;
  500.     bx := dst;
  501.     cx := DTABlk.time;
  502.     dx := DTABlk.date;
  503.     msdos(regs);
  504.     checkerror(Flags and 1);
  505.    end;
  506.   with regs do
  507.    begin
  508.     ah := $3E;
  509.     bx := src;
  510.     msdos(regs);
  511.     ferror := ferror or ((flags and 1) <> 0);
  512.     ah := $3E;
  513.     bx := dst;
  514.     msdos(regs);
  515.     ferror := ferror or ((flags and 1) <> 0)
  516.    end;
  517.   if ferror then exit else
  518.    with regs do
  519.     begin
  520.      ah := $43;
  521.      al := 1;
  522.      cx := DTABlk.attr;
  523.      ds := Seg(nName[1]);
  524.      dx := ofs(nName[1]);
  525.      msdos(regs);
  526.      if checkerror(Flags and 1) then exit else if (cWHAT = cMOVE) then delFile(orig)
  527.     end;
  528. end;
  529.  
  530. (***************************************************************************
  531.   function copy_file();  Copies file 'IP' to file 'OP', sets attribute to
  532.   Archive, and returns errorcode.
  533.  ***************************************************************************)
  534.  
  535. function copy_file(from, too: string): integer;
  536. begin
  537.  IP:=from; OP:=too;
  538.  copy_file:= Copier(cCOPY,IP,OP);
  539.  if exist(OP) then PutFAttr(OP,false,false,false,true);
  540. end;
  541.  
  542. (***************************************************************************
  543.                                End Copy Routines
  544.  ***************************************************************************)
  545.  
  546. (***************************************************************************
  547.   function convert_address();  Converts a Fidonet style address to a
  548.   string suitable for use as a filename.  (IE:  1:2230/146 would be
  549.   converted to 12230146)
  550.  ***************************************************************************)
  551.  
  552. function convert_address(s: string): string;
  553. var
  554.  s1: string[8];
  555.  i: byte;
  556.  
  557. begin
  558.  s1:='';
  559.  for i:=1 to length(s) do
  560.   begin
  561.    if ((s[i]<>':') and (s[i]<>'/') and (s[i]<>'.')) then s1:=s1+s[i];
  562.   end;
  563.  convert_address:=s1;
  564. end;
  565.  
  566. (***************************************************************************
  567.   procedure compress_outgoing();  ZIP's up all files in the outgoing
  568.   directory (outfiles) into a file called ????????.ZIP (passed as 'filename')
  569.   in the outgoing ZIP directory (outzip).  If successful, outfile\*.* is
  570.   deleted.
  571.  ***************************************************************************)
  572.  
  573. procedure compress_outgoing(filename: string; killem: boolean);
  574. var
  575.  error: integer;
  576.  
  577. begin
  578.  error:=doexec('PKZIP.EXE','-EX '+outzip+filename+' '+outfiles+'*.*');
  579.  if error<>0 then
  580.   begin
  581.    writeln(^G^G,#254,'  ERROR:  Errorcode:= ',error);
  582.    delay(2500);
  583.   end
  584.  else if killem then
  585.   begin
  586.    killdir(outfiles);
  587.    makepath(outfiles);
  588.   end;
  589. end;
  590.  
  591. (***************************************************************************
  592.   procedure decompress();  Decompresses all ZIP files in incoming directory
  593.   (inzip) into the infiles directory (infiles).  If successfule, all ZIP
  594.   files are deleted.
  595.  ***************************************************************************)
  596.  
  597. procedure decompress_incoming;
  598. var
  599.  error: integer;
  600.  dirinfo: searchrec;
  601.  f: file;
  602.  
  603. begin
  604.  findfirst('*.ZIP',archive,dirinfo);
  605.  while doserror=0 do
  606.   begin
  607.    error:=doexec('PKUNZIP.EXE','-EX '+inzip+dirinfo.name+' '+infiles);
  608.    if error<>0 then
  609.     begin
  610.      writeln(^G^G,#254,'  ERROR:  Errorcode:= ',error);
  611.      delay(2500);
  612.     end
  613.    else
  614.     begin
  615.      assign(f,outfiles+dirinfo.name);
  616.      erase(f);
  617.     end;
  618.    findnext(dirinfo);
  619.   end;
  620. end;
  621.  
  622. (***************************************************************************
  623.   procedure get_message();  Does the actual reading of *.MSG files.
  624.   Called from get_ibbs_incoming(); and read_all_messages().
  625.  ***************************************************************************)
  626.  
  627. procedure get_message(file_name: string; var cur_msg: message_rec);
  628. type
  629.  msg_buff=array[1..65535] of char;
  630.  msg_buff_ptr=^msg_buff;
  631.  
  632. var
  633.  ss: array[1..2] of char;
  634.  c: integer absolute ss;
  635.  d: integer;
  636.  message_buffer: msg_buff_ptr;
  637.  f: file;
  638.  l, a, bfcnt: integer;
  639.  b: boolean;
  640.  ch: char;
  641.  s: string;
  642.  
  643. begin
  644.  oldfilemode:=filemode;
  645.  filemode:=64;
  646.  assign(f,file_name);
  647.  {$I-}
  648.  filemode:=66;
  649.  reset(f,128);
  650.  filemode:=2;
  651.  {$I+}
  652.  if ioresult<>0 then cur_msg.from:='DELETED' else
  653.   begin
  654.    getmem(message_buffer,(filesize(f)+2)*128);
  655.    for a:=1 to (filesize(f)+2)*128 do message_buffer^[a]:=#0;
  656.    blockread(f,message_buffer^,filesize(f)+1,a);
  657.    cur_msg.from:='';
  658.    cur_msg.too:='';
  659.    cur_msg.subject:='';
  660.    cur_msg.datetime:='';
  661.    b:=true;
  662.    for a:=1 to 36 do
  663.     begin
  664.      if message_buffer^[a]=#0 then b:=false;
  665.      if b then cur_msg.from:=cur_msg.from+message_buffer^[a];
  666.     end;
  667.    b:=true;
  668.   for a:=37 to 73 do
  669.    begin
  670.     if message_buffer^[a]=#0 then b:=false;
  671.     if b then cur_msg.too:=cur_msg.too+message_buffer^[a];
  672.    end;
  673.   b:=true;
  674.   for a:=73 to 145 do
  675.    begin
  676.     if message_buffer^[a]=#0 then b:=false;
  677.     if b then cur_msg.subject:=cur_msg.subject+message_buffer^[a];
  678.    end;
  679.   b:=true;
  680.   for a:=145 to 165 do
  681.    begin
  682.     if message_buffer^[a]=#0 then b:=false;
  683.     if b then cur_msg.datetime:=cur_msg.datetime+message_buffer^[a];
  684.    end;
  685.   ss[1]:=message_buffer^[167];
  686.   ss[2]:=message_buffer^[168];
  687.   cur_msg.destnode:=c;
  688.   ss[1]:=message_buffer^[169];
  689.   ss[2]:=message_buffer^[170];
  690.   cur_msg.orignode:=c;
  691.   ss[1]:=message_buffer^[171];
  692.   ss[2]:=message_buffer^[172];
  693.   cur_msg.cost:=c;
  694.   ss[1]:=message_buffer^[173];
  695.   ss[2]:=message_buffer^[174];
  696.   cur_msg.orignet:=c;
  697.   ss[1]:=message_buffer^[175];
  698.   ss[2]:=message_buffer^[176];
  699.   cur_msg.destnet:=c;
  700.   ss[1]:=message_buffer^[185];
  701.   ss[2]:=message_buffer^[186];
  702.   cur_msg.replyto:=c;
  703.   ss[1]:=message_buffer^[187];
  704.   ss[2]:=message_buffer^[188];
  705.   cur_msg.attribute:=c;
  706.   ss[1]:=message_buffer^[189];
  707.   ss[2]:=message_buffer^[190];
  708.   cur_msg.nextreply:=c;
  709.   l:=1;
  710.   for a:=1 to 100 do cur_msg.text[a]:='';
  711.   bfcnt:=191;
  712.   repeat
  713.    ch:=message_buffer^[bfcnt];
  714.    bfcnt:=succ(bfcnt);
  715.    if ch=#$0D then inc(l);
  716.    if not (ch in [#$0d,#$8d,#$0a,#0]) then cur_msg.text[l]:=cur_msg.text[l]+ch;
  717.    if (length(cur_msg.text[l])=79) then
  718.     begin
  719.      d:=0;
  720.      for c:=length(cur_msg.text[l]) downto 1 do
  721.       begin
  722.        if (d=0) and (cur_msg.text[l][c]=' ') then d:=c;
  723.       end;
  724.     s:='';
  725.     if d>60 then
  726.      begin
  727.       while length(cur_msg.text[l])>=d do
  728.        begin
  729.         s:=s+cur_msg.text[l][length(cur_msg.text[l])];
  730.         delete(cur_msg.text[l],length(cur_msg.text[l]),1);
  731.        end;
  732.       for a:=length(s)-1 downto 1 do cur_msg.text[l+1]:=cur_msg.text[l+1]+s[a];
  733.      end;
  734.     inc(l);
  735.     end;
  736.    if l>=99 then
  737.     begin
  738.      cur_msg.text[99]:='<Error: Too many lines in message>';
  739.      l:=99;
  740.      ch:=#0;
  741.     end;
  742.   until ch=chr(0);
  743.   cur_msg.lines:=l;
  744.   freemem(message_buffer,(filesize(f)+2)*128);
  745.   close(f);
  746.  end;
  747.  filemode:=oldfilemode;
  748. end;
  749.  
  750. (***************************************************************************
  751.   procedure write_message();  Does the actual writing of *.MSG files.
  752.   Called from make_ibbs_outgoing();.
  753.  ***************************************************************************)
  754.  
  755. procedure write_message(file_name: string; var cur_msg: message_rec);
  756. var
  757.  f: file of char;
  758.  i, i1: integer;
  759.  ch, ch1: char;
  760.  cr: char;
  761.  space: char;
  762.  soft_cr: char;
  763.  ss: array[1..10] of char;
  764.  
  765. begin
  766.  while length(cur_msg.subject)>71 do delete(cur_msg.subject,length(cur_msg.subject),1);
  767.  i1:=0;
  768.  assign(f,file_name);
  769.  rewrite(f);
  770.  for i:=1 to length(cur_msg.from) do
  771.   begin
  772.    write(f,cur_msg.from[i]);
  773.    inc(i1);
  774.   end;
  775.  space:=#32; ch:=#0; ch1:=#01; cr:=#$0d; soft_cr:=#$08d;
  776.  while i1<36 do
  777.   begin
  778.    write(f,ch);
  779.    inc(i1);
  780.   end;
  781.  for i:=1 to length(cur_msg.too) do
  782.   begin
  783.    write(f,cur_msg.too[i]);
  784.    inc(i1);
  785.   end;
  786.  while i1<72 do
  787.   begin
  788.    write(f,ch);
  789.    inc(i1);
  790.   end;
  791.  for i:=1 to length(cur_msg.subject) do
  792.   begin
  793.    write(f,cur_msg.subject[i]);
  794.    inc(i1);
  795.   end;
  796.  while i1<144 do
  797.   begin
  798.    write(f,ch);
  799.    inc(i1);
  800.   end;
  801.  for i:=1 to length(cur_msg.datetime) do
  802.   begin
  803.    write(f,cur_msg.datetime[i]);
  804.    inc(i1);
  805.   end;
  806.  while i1<164 do
  807.   begin
  808.    write(f,ch);
  809.    inc(i1);
  810.   end;
  811.  write(f,ch1,ch);
  812.  with cur_msg do
  813.   begin
  814.    ss[1]:=chr(lo(destnode));
  815.    ss[2]:=chr(hi(destnode));
  816.    ss[3]:=chr(lo(orignode));
  817.    ss[4]:=chr(hi(orignode));
  818.    ss[5]:=chr(lo(cost));
  819.    ss[6]:=chr(hi(cost));
  820.    ss[7]:=chr(lo(orignet));
  821.    ss[8]:=chr(hi(orignet));
  822.    ss[9]:=chr(lo(destnet));
  823.    ss[10]:=chr(hi(destnet));
  824.    for i:=1 to 10 do write(f,ss[i]);
  825.    write(f,ch,ch,ch,ch,ch,ch,ch,ch);
  826.    ss[1]:=chr(lo(replyto));
  827.    ss[2]:=chr(hi(replyto));
  828.    ss[3]:=chr(lo(attribute));
  829.    ss[4]:=chr(hi(attribute));
  830.    ss[5]:=chr(lo(nextreply));
  831.    ss[6]:=chr(hi(nextreply));
  832.    for i:=1 to 6 do write(f,ss[i]);
  833.   end;
  834.  for i:=1 to cur_msg.lines do
  835.   begin
  836.    for i1:=1 to length(cur_msg.text[i]) do write(f,cur_msg.text[i][i1]);
  837.    if cur_msg.text[i][length(cur_msg.text[i])]<>#13 then write(f,space);
  838.   end;
  839.  write(f,ch);
  840.  close(f);
  841. end;
  842.  
  843. (***************************************************************************
  844.   function find_high_message(); Returns value of highest *.MSG file found
  845.   in path 'path'.  Called from make_ibbs_outgoing();.
  846.  ***************************************************************************)
  847.  
  848. function find_high_message(path: string): word;
  849. var
  850.  sr: searchrec;
  851.  a, b, highmsg: integer;
  852.  s: string;
  853.  
  854. begin
  855.  highmsg:=0; s:='';
  856.  findfirst(path+'\'+'*.msg',anyfile,sr);
  857.  for a:=1 to pos('.',sr.name)-1 do s:=s+sr.name[a];
  858.  a:=value(s);
  859.  if a<>0 then if a>highmsg then highmsg:=a;
  860.  while doserror=0 do
  861.   begin
  862.    findnext(sr);
  863.    s:='';
  864.    for a:=1 to pos('.',sr.name)-1 do s:=s+sr.name[a];
  865.    a:=value(s);
  866.    if a<>0 then if a>highmsg then highmsg:=a;
  867.   end;
  868.  find_high_message:=highmsg;
  869. end;
  870.  
  871. (***************************************************************************
  872.   function fidodate;  Returns current date in Fido format.
  873.   Called from make_ibbs_outgoing();.
  874.  ***************************************************************************)
  875.  
  876. function fidodate: string;
  877. const
  878.  months: array[1..12] of string[3] = ('Jan', 'Feb', 'Mar', 'Apr',
  879.                                        'May', 'Jun', 'Jul', 'Aug',
  880.                                        'Sep', 'Oct', 'Nov', 'Dec');
  881.  
  882. var
  883.  y, m, d, w: word;
  884.  h, mn, sc, s100: word;
  885.  s, s2: string;
  886.  
  887. begin
  888.  getdate(y,m,d,w);
  889.  y:=y-1900;
  890.  s:=cstr(d);
  891.  if length(s)=1 then s:='0'+s;
  892.  s:=s+' '+months[m]+' '+cstr(y)+'  ';
  893.  gettime(h,mn,sc,s100);
  894.  s2:=cstr(h);
  895.  if length(s2)=1 then s2:='0'+s2;
  896.  s:=s+s2+':'; s2:=cstr(mn);
  897.  if length(s2)=1 then s2:='0'+s2;
  898.  s:=s+s2+':'; s2:=cstr(sc);
  899.  if length(s2)=1 then s2:='0'+s2;
  900.  s:=s+s2;
  901.  s:=s+#0;
  902.  while length(s)>20 do delete(s,length(s),1);
  903.  fidodate:=s;
  904. end;
  905.  
  906. (***************************************************************************
  907.   function getbit();  Returns TRUE if specified bit is set else FALSE.
  908.   Called from togglebit(); and do_bit.
  909.  ***************************************************************************)
  910.  
  911. function getbit(the_bit: word; which_bit: byte): boolean;
  912. begin
  913.  if (the_bit and (1 shl which_bit))<>0 then getbit:=true else getbit:=false;
  914. end;
  915.  
  916. (***************************************************************************
  917.   function setbit();  If setit=true, the specified bit is set, else it's
  918.   cleared.  Called from togglebit(); and make_ibbs_outgoing();.
  919.  ***************************************************************************)
  920.  
  921. procedure setbit(var the_bit: word; which_bit: byte; setit: boolean);
  922. begin
  923.  if setit then the_bit:=the_bit or (1 shl which_bit) else the_bit:=the_bit and not (1 shl which_bit);
  924. end;
  925.  
  926. (***************************************************************************
  927.   function togglebit();  Toggles the status of the specified bit
  928.   Not used.
  929.  ***************************************************************************)
  930.  
  931. procedure togglebit(var the_bit: word; which_bit: byte);
  932. begin
  933.  if getbit(the_bit,which_bit) then setbit(the_bit,which_bit,false) else setbit(the_bit,which_bit,true)
  934. end;
  935.  
  936. (***************************************************************************
  937.   function do_bit();  Reports which bit(s) in cur_msg.attributes are ON.
  938.   Called from read_all_msgs();.
  939.  ***************************************************************************)
  940.  
  941. {$IFDEF READ_EM}
  942. procedure do_bit(the_bit, num: word);
  943. begin
  944.  case num of
  945.   0 : if getbit(the_bit,num) then writeln('Private Message');
  946.   1 : if getbit(the_bit,num) then writeln('Crashmail');
  947.   2 : if getbit(the_bit,num) then writeln('Message Was Read');
  948.   3 : if getbit(the_bit,num) then writeln('Message Was Sent');
  949.   4 : if getbit(the_bit,num) then writeln('File Attatched, Filename(s) In Subject');
  950.   5 : if getbit(the_bit,num) then writeln('Forwarded Message');
  951.   6 : if getbit(the_bit,num) then writeln('Orphan Message');
  952.   7 : if getbit(the_bit,num) then writeln('Kill After It''s Sent');
  953.   8 : if getbit(the_bit,num) then writeln('Message Originated Here (Local)');
  954.   9 : if getbit(the_bit,num) then writeln('Hold');
  955.  10 : if getbit(the_bit,num) then writeln('Reserved');
  956.  11 : if getbit(the_bit,num) then writeln('File Request, Filename(s) In Subject');
  957.  12 : if getbit(the_bit,num) then writeln('Return Receipt Requested');
  958.  13 : if getbit(the_bit,num) then writeln('This message is a Return Receipt');
  959.  14 : if getbit(the_bit,num) then writeln('Audit Trail Requested');
  960.  15 : if getbit(the_bit,num) then writeln('Update Request');
  961.  end;
  962. end;
  963. {$ENDIF}
  964.  
  965. (***************************************************************************
  966.   procedure read_all_msgs();  Displays all *.MSG files in path 'path'.
  967.  ***************************************************************************)
  968.  
  969. {$ifdef READ_EM}
  970. procedure read_all_msgs;
  971. var
  972.  ii: byte;
  973.  dirinfo: searchrec;
  974.  
  975. begin
  976.  findfirst(netmailpath+'*.MSG',archive,dirinfo);
  977.  while doserror=0 do
  978.   begin
  979.    clrscr;
  980.    writeln('Message: ',dirinfo.name);
  981.    get_message(netmailpath+dirinfo.name, cur_msg);
  982.    writeln('From: ',cur_msg.from,'  ',cur_msg.orignet,'/',cur_msg.orignode);
  983.    writeln('To  : ',cur_msg.too,'  ',cur_msg.destnet,'/',cur_msg.destnode);
  984.    writeln('Date/Time: ',cur_msg.datetime);
  985.    writeln('Subject: ',cur_msg.subject);
  986.    writeln('Attr: ',cur_msg.attribute);
  987.    for ii:=0 to 15 do do_bit(cur_msg.attribute,ii);
  988.    for ii:=1 to 80 do write(#254);
  989.    window(1,wherey,80,25);
  990.    for ii:=1 to cur_msg.lines do writeln(cur_msg.text[ii]);
  991.    readkey;
  992.    window(1,1,80,25);
  993.    findnext(dirinfo);
  994.   end;
  995. end;
  996. {$endif}
  997.  
  998. (***************************************************************************
  999.   procedure get_ibbs_incoming();  Checks all incoming netmailpath\*.MSG
  1000.   files for messages addresses to 'name' @ 'this_system_address', moves
  1001.   file found in 'filepath' to 'doorpath\inzip' and deletes the *.MSG.
  1002.  ***************************************************************************)
  1003.  
  1004. procedure get_ibbs_incoming;
  1005. var
  1006.  ok: boolean;
  1007.  i, i1: word;
  1008.  b, b1: byte;
  1009.  tempstr, tostr, fromstr, thefile: string;
  1010.  dirinfo: searchrec;
  1011.  
  1012. begin
  1013.  i1:=0; tostr:=''; fromstr:='';
  1014.  for i:=1 to cur_msg.lines do
  1015.   begin
  1016.    if pos('IBBS:',cur_msg.text[i])<>0 then i1:=i;
  1017.    if i1<>0 then i:=cur_msg.lines;
  1018.   end;
  1019.  if i1<>0 then
  1020.   begin
  1021.    tostr:=field(cur_msg.text[i1],#32,2);
  1022.    fromstr:=field(cur_msg.text[i1],#32,3);
  1023.   end;
  1024.  findfirst(netmailpath+'*.MSG',archive,dirinfo);
  1025.  while doserror=0 do
  1026.   begin
  1027.    clrscr; tempstr:=''; ok:=true;
  1028.    writeln('Message: ',dirinfo.name);
  1029.    get_message(netmailpath+dirinfo.name, cur_msg);
  1030.    for i:=1 to cur_msg.lines do
  1031.     begin
  1032.      if pos('TID',cur_msg.text[i])<>0 then tempstr:=cur_msg.text[i];
  1033.      if tempstr<>'' then i:=cur_msg.lines;
  1034.     end;
  1035.    if tempstr<>'' then if (pos('IBBS / '+the_doorname,tempstr)<>0) then ok:=true else ok:=false;
  1036.    if ((upstr(cur_msg.too) = (upstr(the_doorname))) and (tostr=this_system_address) and (ok)) then
  1037.     begin
  1038.      thefile:=cur_msg.subject;
  1039.      if pos('\',thefile)<>0 then
  1040.       begin
  1041.        for b:=1 to length(thefile) do if thefile[b]='\' then b1:=b;
  1042.        delete(thefile,1,b1);
  1043.       end;
  1044.      writeln('Copying ',upstr(filepath+thefile),' to ',upstr(doorpath+inzip+thefile));
  1045.      if exist(filepath+thefile) then
  1046.       writeln('Return Code: ',copy_file(filepath+thefile,doorpath+inzip+thefile))
  1047.        else writeln(upstr(filepath+thefile),' doesn''t exist!');
  1048.      killmsg(netmailpath+dirinfo.name);
  1049.      writeln('Killing: ',upstr(netmailpath+dirinfo.name));
  1050.     end;
  1051.    findnext(dirinfo);
  1052.  end;
  1053.  decompress_incoming;
  1054. end;
  1055.  
  1056. (***************************************************************************
  1057.   procedure make_ibbs_outgoing();  Creates the outgoing netmailpath\*.MSG.
  1058.   Sets message as: To 'doorname' @ 'toaddr', From 'doorname' @ 'fromaddr',
  1059.   subjext is 'thefile', set as attributes/flags are set as Pvt, Local, File,
  1060.   Kill, Del/Sent, Direct.
  1061.  ***************************************************************************)
  1062.  
  1063. procedure make_ibbs_outgoing(thefile: string; killfiles: boolean);
  1064. var
  1065.  i: word;
  1066.  save_this, too, from, tnode, fnode, tnet, fnet: string;
  1067.  
  1068. begin
  1069.  save_this:=this_system_address;
  1070.  clrscr; writeln('Sending '+upstr(thefile)+'.ZIP to '+to_system_address);
  1071.  compress_outgoing(thefile,killfiles);
  1072.  thefile:=doorpath+outzip+thefile+'.ZIP';
  1073.  if exist(thefile) then
  1074.   begin
  1075.    too:=''; from:=''; tnode:=''; tnet:=''; fnet:=''; i:=0;
  1076.    i:=find_high_message(netmailpath)+1;
  1077.    too:=to_system_address; from:=this_system_address;
  1078.    while to_system_address[1]<>':' do delete(to_system_address,1,1);
  1079.    delete(to_system_address,1,1);
  1080.    while to_system_address[1]<>'/' do
  1081.     begin tnet:=tnet+to_system_address[1]; delete(to_system_address,1,1); end;
  1082.    delete(to_system_address,1,1);
  1083.    tnode:=to_system_address;
  1084.    while this_system_address[1]<>':' do delete(this_system_address,1,1);
  1085.    delete(this_system_address,1,1);
  1086.    while this_system_address[1]<>'/' do
  1087.     begin fnet:=fnet+this_system_address[1]; delete(this_system_address,1,1); end;
  1088.    delete(this_system_address,1,1);
  1089.    fnode:=this_system_address;
  1090.    cur_msg.from:=the_doorname;
  1091.    cur_msg.too:=the_doorname;
  1092.    cur_msg.subject:=upstr(thefile);
  1093.    cur_msg.datetime:=fidodate;
  1094.    cur_msg.destnode:=value(tnode);
  1095.    cur_msg.orignode:=value(fnode);
  1096.    cur_msg.cost:=11;
  1097.    cur_msg.orignet:=value(fnet);
  1098.    cur_msg.destnet:=value(tnet);
  1099.    setbit(cur_msg.attribute,0,true);
  1100.    setbit(cur_msg.attribute,1,true);
  1101.    setbit(cur_msg.attribute,2,false);
  1102.    setbit(cur_msg.attribute,3,false);
  1103.    setbit(cur_msg.attribute,4,true);
  1104.    setbit(cur_msg.attribute,5,false);
  1105.    setbit(cur_msg.attribute,6,false);
  1106.    setbit(cur_msg.attribute,7,true);
  1107.    setbit(cur_msg.attribute,8,true);
  1108.    setbit(cur_msg.attribute,9,false);
  1109.    setbit(cur_msg.attribute,10,false);
  1110.    setbit(cur_msg.attribute,11,false);
  1111.    setbit(cur_msg.attribute,12,false);
  1112.    setbit(cur_msg.attribute,13,false);
  1113.    setbit(cur_msg.attribute,14,false);
  1114.    setbit(cur_msg.attribute,15,false);
  1115.    cur_msg.lines:=4;
  1116.    cur_msg.text[1]:=#1+'IBBS: '+too+' '+from+' '+#10+#13;
  1117.    cur_msg.text[2]:=#1+'INTL '+too+' '+from+' '+#10+#13;
  1118.    cur_msg.text[3]:=#1+'FLAGS DIR KFS'+#10+#13;
  1119.    cur_msg.text[4]:=#1+'TID: IBBS / '+the_doorname+#10+#13;
  1120.    write_message(netmailpath+cstr(i)+'.MSG', cur_msg);
  1121.    this_system_address:=save_this;
  1122.   end
  1123.  else writeln(upstr(thefile)+' doesn''t exist!');
  1124. end;
  1125.  
  1126. (***************************************************************************
  1127.    procedure make_multi_ibbs_outgoing();  Reads each line in ROUTE.CFG,
  1128.    and calls make_ibbs_outgoing for each line.
  1129.  ***************************************************************************)
  1130.  
  1131. procedure make_multi_ibbs_outgoing;
  1132. var
  1133.  t: text;
  1134.  savenode, s: string;
  1135.  
  1136. begin
  1137.  savenode:=to_system_address;
  1138.  if not exist('ROUTE.CFG') then
  1139.   begin
  1140.    writeln(^G^G,#254,'  ERROR:  ROUTE.CFG Does NOT exist!');
  1141.    delay(2500);
  1142.   end
  1143.  else
  1144.   begin
  1145.    assign(t,'ROUTE.CFG');
  1146.    reset(t);
  1147.    while not eof(t) do
  1148.     begin
  1149.      readln(t,s);
  1150.      if ((s<>'') and (s[1]<>';')) then
  1151.       begin
  1152.        to_system_address:=field(s,';',1);
  1153.        make_ibbs_outgoing(field(s,';',2),false);
  1154.       end;
  1155.     end;
  1156.    close(t);
  1157.    killdir(outfiles);
  1158.    makepath(outfiles);
  1159.   end;
  1160.  to_system_address:=savenode;
  1161. end;
  1162.  
  1163. (***************************************************************************
  1164.   procedure read_config();  Reads the IBBS.CFG file, or creates it if it
  1165.   doesn't exist.
  1166.  ***************************************************************************)
  1167.  
  1168. procedure read_config;
  1169. var
  1170.  t: text;
  1171.  
  1172. procedure ask_dir(path: string);
  1173. var
  1174.  sel: char;
  1175.  
  1176. begin
  1177.  if path[length(path)]<>'\' then path:=path+'\';
  1178.  write(upstr(path)+' doesn''t exist, create it [Y/n]: ');
  1179.  onek(sel,'YN'+#13+#10);
  1180.  case sel of
  1181.   #10,
  1182.   #13,
  1183.   'Y': begin
  1184.         writeln('Yes');
  1185.         makepath(path);
  1186.        end;
  1187.   'N': writeln('Yes');
  1188.  end;
  1189. end;
  1190.  
  1191.  
  1192. begin
  1193.  getdir(0,doorpath);
  1194.  if not exist('IBBS.CFG') then
  1195.   begin
  1196.    assign(t,'IBBS.CFG');
  1197.    rewrite(t);
  1198.    clrscr;
  1199.    writeln('IBBS.CFG doesn''t exist.  Creating now...'); writeln;
  1200.    repeat
  1201.     write('Enter your net address [ie: 1:2230/146]              : '); readln(this_system_address);
  1202.    until this_system_address<>'';
  1203.    repeat
  1204.     write('Enter the TO net address [ie: 1:391/3010]            : '); readln(to_system_address);
  1205.    until to_system_address<>'';
  1206.    repeat
  1207.     write('Enter the door''s name                                : '); readln(the_doorname);
  1208.    until the_doorname<>'';
  1209.    repeat
  1210.     write('Enter your FULL netmail path [ie: C:\FD\NETMAIL\]    : '); readln(netmailpath);
  1211.     if not direxist(netmailpath) then ask_dir(netmailpath);
  1212.    until direxist(netmailpath) and (netmailpath<>'');
  1213.    repeat
  1214.     write('Enter your FULL incoming files path [ie:C:\FD\FILE\] : '); readln(filepath);
  1215.     if not direxist(filepath) then ask_dir(filepath);
  1216.    until direxist(filepath) and (filepath<>'');
  1217.    repeat
  1218.     write('Enter your UNZIP directory NAME [ie: INFILES]        : '); readln(infiles);
  1219.     if not direxist(infiles) then ask_dir(infiles);
  1220.    until direxist(infiles) and (infiles<>'');
  1221.    repeat
  1222.     write('Enter your ZIP files directory NAME [ie: OUTFILES]   : '); readln(outfiles);
  1223.     if not direxist(outfiles) then ask_dir(outfiles);
  1224.    until direxist(outfiles) and (outfiles<>'');
  1225.    repeat
  1226.     write('Enter your outgoing ZIP directory NAME [ie: OUTZIP]  : '); readln(outzip);
  1227.     if not direxist(outzip) then ask_dir(outzip);
  1228.    until direxist(outzip) and (outzip<>'');
  1229.    repeat
  1230.     write('Enter your incoming ZIP directory NAME [ie: INZIP]   : '); readln(inzip);
  1231.     if not direxist(inzip) then ask_dir(inzip);
  1232.    until direxist(inzip) and (inzip<>'');
  1233.    writeln(t,this_system_address);
  1234.    writeln(t,to_system_address);
  1235.    writeln(t,the_doorname);
  1236.    writeln(t,upstr(netmailpath));
  1237.    writeln(t,upstr(filepath));
  1238.    writeln(t,upstr(infiles));
  1239.    writeln(t,upstr(outfiles));
  1240.    writeln(t,upstr(outzip));
  1241.    writeln(t,'');
  1242.    writeln(t,'(**************  IBBS.CFG - Everything after line 9 is ignored. ************)');
  1243.    writeln(t,'Line 1:  Your Net Address');
  1244.    writeln(t,'Line 2:  The To Net Address');
  1245.    writeln(t,'Line 3:  This Door''s Name');
  1246.    writeln(t,'Line 4:  Netmail Path');
  1247.    writeln(t,'Line 5:  Incoming File Path');
  1248.    writeln(t,'Line 6:  Name Of Directory To Decompress Incoming Files To');
  1249.    writeln(t,'Line 7:  Name Of Directory Holding Outgoing Files To Be Compressed');
  1250.    writeln(t,'Line 8:  Name Of Directory Holding Compressed Outgoing Files');
  1251.    writeln(t,'Line 9:  Name Of Directory Holding Compressed Incoming Files');
  1252.    close(t);
  1253.   end;
  1254.  assign(t,'IBBS.CFG');
  1255.  reset(t);
  1256.  readln(t,this_system_address);
  1257.  readln(t,to_system_address);
  1258.  readln(t,the_doorname);
  1259.  readln(t,netmailpath);
  1260.  readln(t,filepath);
  1261.  readln(t,infiles);
  1262.  readln(t,outfiles);
  1263.  readln(t,outzip);
  1264.  readln(t,inzip);
  1265.  close(t);
  1266. end;
  1267.  
  1268. (***************************************************************************
  1269.   procedure check_dirs();  Insures all the directories exist, and creates
  1270.   them if not.
  1271.  ***************************************************************************)
  1272.  
  1273. procedure check_dirs;
  1274. begin
  1275.  if not direxist(netmailpath) then makepath(netmailpath);
  1276.  if not direxist(filepath) then makepath(filepath);
  1277.  if not direxist(infiles) then makepath(infiles);
  1278.  if not direxist(outfiles) then makepath(outfiles);
  1279.  if not direxist(outzip) then makepath(outzip);
  1280.  if not direxist(inzip) then makepath(inzip);
  1281. end;
  1282.  
  1283. (***************************************************************************
  1284.   procedure check_slashes();  Insures all the directory names have a
  1285.   trailing backslash, and appens one if not.
  1286.  ***************************************************************************)
  1287.  
  1288. procedure check_slashes;
  1289. begin
  1290.  if outfiles[length(outfiles)]<>'\' then outfiles:=outfiles+'\';
  1291.  if infiles[length(infiles)]<>'\' then infiles:=infiles+'\';
  1292.  if outzip[length(outzip)]<>'\' then outzip:=outzip+'\';
  1293.  if inzip[length(inzip)]<>'\' then inzip:=inzip+'\';
  1294.  if netmailpath[length(netmailpath)]<>'\' then netmailpath:=netmailpath+'\';
  1295.  if filepath[length(filepath)]<>'\' then filepath:=filepath+'\';
  1296.  if doorpath[length(doorpath)]<>'\' then doorpath:=doorpath+'\';
  1297. end;
  1298.  
  1299. (***************************************************************************
  1300.                               Begin Main Block
  1301.  ***************************************************************************)
  1302.  
  1303. BEGIN
  1304.  read_config;
  1305.  check_slashes;
  1306.  check_dirs;
  1307. END.
  1308.  
  1309.  
  1310.  
  1311. { IBBS.CFG
  1312.  
  1313. 1:2230/146
  1314. 1:391/3010
  1315. DoorName
  1316. C:\FD\NETMAIL\
  1317. C:\FD\FILE\
  1318. INFILES
  1319. OUTFILES
  1320. OUTZIP
  1321. INZIP
  1322.  
  1323. (**************  IBBS.CFG - Everything after line 9 is ignored. ************)
  1324. Line 1:  Your Net Address
  1325. Line 2:  The To Net Address
  1326. Line 3:  This Door's Name
  1327. Line 4:  Netmail Path
  1328. Line 5:  Incoming File Path
  1329. Line 6:  Name Of Directory To Decompress Incoming Files To
  1330. Line 7:  Name Of Directory Holding Outgoing Files To Be Compressed
  1331. Line 8:  Name Of Directory Holding Compressed Outgoing Files
  1332. Line 9:  Name Of Directory Holding Compressed Incoming Files
  1333.  
  1334. }